package org.lee.basic.algorithm;

/**
 * @author jackielee
 * @version 1.0
 * @description Other1
 * @date 2021/4/19
 */
public class Other1 {
  public static void main(String[] args) {
    System.out.println(getAge(5));

    printReverse(12598);
    System.out.println();

    sushu();
  }

  private static int getAge(int n) {
    if (n == 1) {
      return 10;
    }
    return getAge(n - 1) + 2;
  }

  private static void printReverse(int n) {
    int[] arr = new int[5];
    int i = 0;
    do {
      arr[i++] = n % 10;
      n /= 10;
    } while (n > 0);
    for (i = 0; i < 5; ++i) {
      System.out.print(arr[i]);
    }
  }

  private static void sushu() {
    for (int i = 1; i < 100; ++i) {
      if (isPrime(i)) {
        System.out.print(i + " ");
      }
    }
  }

  private static boolean isPrime(int n) {
    for (int i = 2; i < Math.sqrt(n) + 1; ++i) {
      if (n % i == 0) {
        return false;
      }
    }
    return true;
  }
}
